import request from '@/utils/request'
import { AllDictModel } from '@/api/model/dictModel'
import { DictModel } from '../model/dictModel'
import { PageReq, PageRes } from '../types'

// 获取字典列表
export function dictPageApi(data: PageReq<Partial<DictModel>>) {
  return request<PageRes<DictModel>>({
    url: '/user/dictionaryType/page',
    method: 'post',
    data
  })
}

// 新增字典
export function addDictApi(data: Partial<DictModel>) {
  return request({
    url: '/user/dictionaryType/add',
    method: 'post',
    data
  })
}

// 更新字典
export function editDictApi(data: Partial<DictModel>) {
  return request({
    url: '/user/dictionaryType/edit',
    method: 'post',
    data
  })
}

// 删除字典
export function delDictApi(data: { id: number }) {
  return request({
    url: '/user/dictionaryType/del',
    method: 'post',
    data
  })
}

// 获取字典数据列表
export function dictDataPageApi(data) {
  return request({
    url: '/user/dictionaryData/page',
    method: 'post',
    data
  })
}

// 新增字典数据
export function addDictDataApi(data) {
  return request({
    url: '/user/dictionaryData/add',
    method: 'post',
    data
  })
}

// 更新字典数据
export function editDictDataApi(data) {
  return request({
    url: '/user/dictionaryData/edit',
    method: 'post',
    data
  })
}

// 删除字典数据
export function delDictDataApi(data) {
  return request({
    url: '/user/dictionaryData/del',
    method: 'post',
    data
  })
}

// 按类型查询字典数据
export function allDelDictDataApi(data: any) {
  return request<AllDictModel>({
    url: '/user/dictionaryData/all',
    method: 'post',
    data
  })
}
